package com.astrofizzbizz.downtimesimulator;

public class Device 
{
	private double mttf;
	private double mttr;
	private double tstep;
	private boolean onState = true;
	
	public Device(double mttf, double mttr, double tstep)
	{
		this.mttf = mttf;
		this.mttr = mttr;
		this.tstep = tstep;
		onState = true;
	}
	public void setState()
	{
		double randNum = Math.random();
		if (onState)
		{
			if (randNum <= (tstep / mttf))
			{
				onState = false;
			}
		}
		else
		{
			if (randNum <= (tstep / mttr))
			{
				onState = true;
			}

		}
	}
	public double getMttf() {return mttf;}
	public double getMttr() {return mttr;}
	public boolean isOnState() {return onState;}
}
